<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>报告涨官-思多客</title>
    <link href="http://cdn.bootcss.com/normalize/7.0.0/normalize.min.css" rel="stylesheet">
    <link href="http://cdn.bootcss.com/Swiper/3.4.2/css/swiper.min.css" rel="stylesheet">
    <link rel="stylesheet" href="/public/css/m/public.css">
    <link rel="stylesheet" href="/public/css/m/index.css">
</head>

<body>
    <div class="page n-page">
        <div id="header"></div>
        <div id="nav"></div>
        <div class="content">
            <div class="banner">
                <div class="swiper-container" id="J_swiper">
                    <div class="swiper-wrapper"></div>
                </div>
            </div>
            <div class="report-content">
                <div class="report-nav clearfix" id="J_report_nav">
                    <div class="report-nav-arrow fl" id="J_spread"><img src="/public/images/m/back.png" alt=""></div>
                    <ul class="report-nav-list fl">
                        <li class="J_week" data-week="1">周一</li>
                        <li class="J_week" data-week="2">周二</li>
                        <li class="J_week" data-week="3">周三</li>
                        <li class="J_week" data-week="4">周四</li>
                        <li class="J_week" data-week="5">周五</li>
                        <li class="J_week" data-week="6">周六</li>
                        <li class="J_week" data-week="7">周日</li>
                    </ul>
                </div>
                <!-- 周一~周三 -->
                <div class="report" id="J_product_1">
                    <div class="report-head row">
                        <h2>周一</h2>
                    </div>
                    <div class="report-body clearfix J_product"></div>
                </div>
                <div class="report" id="J_product_2">
                    <div class="report-head row">
                        <h2>周二</h2>
                    </div>
                    <div class="report-body clearfix J_product"></div>
                </div>
                <div class="report" id="J_product_3">
                    <div class="report-head row">
                        <h2>周三</h2>
                    </div>
                    <div class="report-body clearfix J_product"></div>
                </div>
                <div class="report" id="J_product_4">
                    <div class="report-head row">
                        <h2>周四</h2>
                    </div>
                    <div class="report-body clearfix J_product"></div>
                </div>
                <div class="report" id="J_product_5">
                    <div class="report-head row">
                        <h2>周五</h2>
                    </div>
                    <div class="report-body flex J_product"></div>
                </div>
                <div class="report" id="J_product_6">
                    <div class="report-head row">
                        <h2>周六</h2>
                    </div>
                    <div class="report-body flex J_product"></div>
                </div>
                <div class="report row" id="J_product_7">
                    <div class="report-head">
                        <h2>周日</h2>
                    </div>
                    <div class="report-body J_product"></div>
                    <div class="click-load">查看更多</div>
                </div>
            </div>
            <!-- <div class="row rank-content hide">
                <div class="rank-lists">
                    <div class="rank-title clearfix">
                        <h4>周三龙虎榜</h4>
                        <div class="rank-price">原价：
                            <del>138</del>现价：<b>68</b></div>
                        <div class="pay-rank-btn">付费查看</div>
                    </div>
                    <ul class="rank-list">
                        <li>
                            <div class="rank-index">
                                <img src="/public/images/m/rank1.png" alt="">
                            </div>
                            <div class="rank-des">
                                <p class="t">共<b>221</b>位老师共同研究</p>
                                <p class="s">研究战绩：<b>27%</b></p>
                            </div>
                            <div class="rank-infos rank-infos-show">
                                <p>600211 科达股份</p>
                            </div>
                        </li>
                        <li>
                            <div class="rank-index">
                                <img src="/public/images/m/rank2.png" alt="">
                            </div>
                            <div class="rank-des">
                                <p class="t">共<b>221</b>位老师共同研究</p>
                                <p class="s">研究战绩：<b>27%</b></p>
                            </div>
                            <div class="rank-infos rank-infos-hide">
                                <p>600211 科达股份</p>
                            </div>
                        </li>
                        <li>
                            <div class="rank-index">
                                <img src="/public/images/m/rank3.png" alt="">
                            </div>
                            <div class="rank-des">
                                <p class="t">共<b>221</b>位老师共同研究</p>
                                <p class="s">研究战绩：<b>27%</b></p>
                            </div>
                            <div class="rank-infos rank-infos-hide">
                                <p>600211 科达股份</p>
                            </div>
                        </li>
                    </ul>
                </div>
            </div> -->
        </div>
        <div id="footer"></div>
    </div>
    <script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script src="/public/js/m/fontResize.js"></script>
    <script src="http://cdn.bootcss.com/Swiper/3.4.2/js/swiper.min.js"></script>
    <script src="/public/lib/layer/layui.js"></script>
    <script src="/public/js/G.js"></script>
    <script src="/public/js/user.js"></script>
    <script src="/public/js/product.js"></script>
    <script src="/public/js/reward.js"></script>
    <script src="/public/js/rank.js"></script>
    <script src="/public/js/banner.js"></script>
    <script src="/public/js/m/public.js"></script>
    <script id="J_swiper_tpl" type="text/html">
        {{# d.forEach(function(val,index){ }}
        <div class="swiper-slide">
            <img class="swiper-banner" src="{{G.uploadurl + val.originalUrl}}" alt="">
        </div>
        {{# }); }}
    </script>
    <script id="J_productA_tpl" type="text/html">
        {{# d.forEach(function(val,index){ }}
            {{# if(val.free || val.payed){ }}
                <a class="report-item-1 down-free" href="javascript:void(0);" data-id="{{val.productId}}">
            {{# }else{ }}
                <a class="report-item-1" href="/m/payment.html?money={{val.promotionsPrice}}&type=product&title={{val.title}}&userId={{val.teacherId}}&tName={{formatVal(val.aliasName?val.aliasName:val.teacherName)}}&outline={{val.nowContent}}&productId={{val.productId}}&productType={{val.type}}">
            {{# } }}
                <div class="report-body-top clearfix">
                     <img src="/{{G.defaultAvator}}" data-lazyload-img="{{G.uploadurl}}/avator/{{val.teacherId}}.png" class="m-teacher-icon fl">
                    <div class="m-report-info fl">
                        <h4 class="m-report-teacher-name">{{formatVal(val.aliasName?val.aliasName:val.teacherName)}}</h4>
                        <p class="m-focus">{{formatVal(val.sentiment)}}人关注</p>
                        <p class="m-publish-time">{{new Date(val.createTime).format('YYYY/MM/dd')}}</p>
                    </div>
                    <div class="price-tag">
                        {{# if(val.free){ }}
                            <span>免费</span>
                        {{# }else if(val.payed){ }}
                            <span>下载</span>
                        {{# }else{ }}
                            <span>￥{{val.promotionsPrice}}</span>
                        {{# } }}
                    </div>
                </div>
                <div class="report-body-bottom clearfix center m-download-num">下载量:<b>{{formatVal(val.downloadNumber)}}</b>上期战绩:<b>{{formatVal(val.correct)}}%</b></div>
            </a>
        {{# }); }}
    </script>
    <script id="J_productB_tpl" type="text/html">
        {{# d.forEach(function(val,index){ }}
        <a class="report-item-4 flex-1" href="/m/payment.html?money={{val.promotionsPrice}}&type=product&title={{val.title}}&userId={{val.teacherId}}&tName={{formatVal(val.aliasName?val.aliasName:val.teacherName)}}&outline={{val.outline}}&productId={{val.productId}}&productType={{val.type}}">
            <img src="/{{G.defaultCover}}" data-lazyload-img="{{G.uploadurl + val.coverUrl}}">
            <div class="report-item-4-info">
                <!-- <h4 class="report-item-4-jobs">初级实战研究师</h4> -->
                <h3 class="report-item4-name">{{formatVal(val.aliasName?val.aliasName:val.teacherName)}}</h3>
                <p class="report-item-4-fans">下载量: <b>{{formatVal(val.downloadNumber)}}</b>上期战绩: <b>{{formatVal(val.correct)}}%</b></p>
                <p class="report-item-4-price">原价:<b><del>{{formatVal(val.promotionsPrice)}}</del></b>现价:<b>{{formatVal(val.promotionsPrice)}}</b></p>
                <div class="report-item-4-download" href="">付费下载</div>
            </div>
        </a>
        {{# }); }}
    </script>
    <script id="J_reward_tpl" type="text/html">
        {{# d.forEach(function(val,index){ }}
        <div class="report-item-5 reward-list" data-id="{{val.rewardId}}" data-user="{{val.userId}}">
            <div class="report-item-5-head clearfix">
                <img src="/{{G.defaultAvator}}" data-lazyload-img="{{G.uploadurl}}/avator/{{val.userId}}.png" alt="" class="m-rewarder-icon fl">
                <div class="m-rewarder-name fl">{{val.createUser.username}}</div>
                <div class="m-rewarder-time fl">发布了悬赏·{{new Date(val.createTime).format('YYYY-MM-DD HH:ii:ss')}}</div>
            </div>
            <div class="report-item-5-contain clearfix">
                <div class="m-reward-text">{{val.title}}</div>
                <div class="m-reward-btn" data-user="313" data-id="79">发表评论</div>
            </div>
            <div class="m-reward-after"><span class="m-reward-value">{{val.amountPay}}悬赏币</span></div>
        </div>
        {{# }); }}
    </script>
    <script>
    layui.use('laytpl', function() {
        var laytpl = layui.laytpl;
        //banner
        banner.getList({ type: 'wap' }, function(data) {
            laytpl($('#J_swiper_tpl').html()).render(data, function(html) {
                $("#J_swiper .swiper-wrapper").html(html);
            })
            new Swiper('#J_swiper', {
                autoplay: 6000,
                loop: true, //环路
                autoplayDisableOnInteraction: false,
                observer: true, //修改swiper自己或子元素时，自动初始化swiper
                observeParents: true //修改swiper的父元素时，自动初始化swiper
            })
        })
        // getA('A1', 1, 9);
        // getA('A2', 2, 9);
        // getA('A3', 3, 9);
        // getA('A4', 4, 9);
        // getB('B1', 5, 3);
        // getB('B2', 6, 3);

        // getReward();
        var nowDay = new Date().getDay();
        var formatWeek = (nowDay == 0 ? 7 : nowDay);
        $('#J_product_'+ formatWeek).siblings('.report').hide();
        $('#J_product_'+ formatWeek).show();
        var type = '';
        showProductByWeek(formatWeek)

        function renderProduct(tpl, data, week){
            laytpl($(tpl).html()).render(data.list, function(html) {
                $("#J_product_" + week + " .J_product").html(html)
            })
            loading.close()
            lazyload()
        }

        $(document).on('click','.J_week',function(){
            var week = $(this).data('week');
            showProductByWeek(week)
            $('#J_product_'+ week).show();
            $('#J_product_'+ week).siblings('.report').hide()
            $('#J_spread img').removeClass('spread-narrow-show').addClass('spread-narrow-hide')
            $('#J_report_nav').removeClass('spread-show').addClass('spread-hide')
        })

        function showProductByWeek(formatWeek){
            var type = '';
            switch(formatWeek){
                case 1:
                case 2:
                case 3:
                case 4:
                    type = 'A'+formatWeek;
                    getProduct(type, formatWeek, 4, function(data, week){
                        renderProduct('#J_productA_tpl', data, week)
                    });
                    break;
                case 5:
                case 6:
                    type = 'B'+(formatWeek==5?'1':'2');
                    console.log(type)
                    getProduct(type, formatWeek, 4, function(data, week){
                        renderProduct('#J_productB_tpl', data, week)
                    })
                    break;
                case 7:
                    getReward();
                    break; 
                default:
                    loading.close()
                    return;
            }
        }
        function getProduct(type, week, pageSize, callback){
            var params = {
                type: type,
                pageSize: pageSize,
                show: true
            };
            loading.open()
            product.getList(params, function(data) {
                callback(data, week)
            })
        }
        function getReward() {
            reward.getList({
                pageSize: 4
            }, function(data) {
                laytpl($('#J_reward_tpl').html()).render(data.list, function(html) {
                    $("#J_product_7 .J_product").html(html);
                })
                lazyload()
            })
        }
    });
    //导航展开
    $('#J_spread').click(function() {
        var isSpread = $('#J_report_nav').css('right') === '0px' ? true : false;
        $('#J_report_nav').addClass('transition');
        $(this).find('img').addClass('transition');
        if (isSpread) {
            $('#J_report_nav').removeClass('spread-show').addClass('spread-hide')
            $(this).find('img').removeClass('spread-narrow-show').addClass('spread-narrow-hide')
        } else {
            $('#J_report_nav').removeClass('spread-hide').addClass('spread-show')
            $(this).find('img').removeClass('spread-narrow-hide').addClass('spread-narrow-show')
        }
    })
    $(document).on('click','.reward-list',function(){
        var localUserId = G.getCookie('sdk_user_id');
        var userId = $(this).data('user');
        var rewardId = $(this).data('id');
        if(!localUserId){
            location.href = '/m/login.html?from=reward';
            return;
        }
        if(localUserId != userId){
            alert('无法查看他人的悬赏')
            return;
        }
        G.setCookie('localUserId', localUserId, 60 * 24)
        location.href = '/m/reward-detail.html?rewardId=' + rewardId + '&localUserId=' + localUserId
    })
    $('.click-load').click(function(){
        location.href = '/m/reward.html'
    })
    </script>
</body>

</html>